﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DLV.Data.Entities;
using DLV.FrameWork;
using DLV.Library.Utilities;

namespace DLV.BackEnd.Pages
{
    public partial class ExampleAjax : AdminPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack) return;

            LoadType();
            AddValueDefaultForDropdown();
        }

        private void LoadType()
        {
            var ds = new DataSet();
            ds.ReadXml(MapPath("~/xml/ItemType.xml"));
            var dv = ds.Tables["ItemType"].DefaultView;
            ddlType.DataTextField = "Name";
            ddlType.DataValueField = "ID";
            ddlType.DataSource = dv;
            ddlType.DataBind();

            ddlType.Items.Insert(0, new ListItem("--- Chọn loại ---", "-1"));
        }

        private void AddValueDefaultForDropdown()
        {
            ddlConcern.Items.Insert(0, new ListItem("--- Chọn nhà cung cấp ---", "-1"));
            ddlTicket.Items.Insert(0, new ListItem("*", "-1"));
        }
    }
}